<?php

declare(strict_types=1);
/**
 * Author: Zane
 * Email: 873934580@qq.com
 * Date: 2022/4/20.
 */

namespace Zane\View\Providers;

use Illuminate\Http\Client\Factory;

class PendingRequest extends \Illuminate\Http\Client\PendingRequest
{
    public function __construct(Factory $factory = null)
    {
        parent::__construct($factory);
        $this->options['headers'] = $this->param();
    }

    private function param(): array
    {
        return [
            'x-ip' => request()->getClientIp(),
            'x-domain' => request()->getHost(),
            'x-http-domain' => request()->getHttpHost(),
            'x-appid' => config('app.appid', ''),
            'x-server-adder' => $_SERVER['SERVER_ADDR'] ?? '',
            'x-server-name' => $_SERVER['SERVER_NAME'] ?? '',
        ];
    }
}
